package com.jang.controller.cases;

import com.jang.Entity.cases.CaseRuningEntity;
import com.jang.Entity.cases.ConfigEntity;
import com.jang.service.cases.CaseRuningService;
import com.jang.service.cases.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/config")
public class ConfigRestController {
    @Autowired
    ConfigService configService;
    @Autowired
    CaseRuningService caseRuningService;
    /*
    * 环境配置
    * */
    @RequestMapping(value= "/InsertEnv", method = RequestMethod.POST)
    public Object AddEnv(@RequestBody ConfigEntity configEntity){
        Object result = configService.insertEnvConfig(configEntity);
        return result;
    }
    @RequestMapping(value= "/UpdateEnv", method = RequestMethod.POST)
    public Object UpdateEnv(@RequestBody ConfigEntity configEntity){
        Object result = configService.updateEnvConfig(configEntity);
        return result;
    }
    @RequestMapping(value= "/DelEnv", method = RequestMethod.POST)
    public Object DelEnv(@RequestBody ConfigEntity configEntity){
        Object result = configService.DelEnvConfig(configEntity);
        return result;
    }
    @RequestMapping(value= "/EnvList", method = RequestMethod.POST)
    public Object EnvList(){
        Object result = configService.getEnvConfig();
        return result;
    }
    @RequestMapping(value= "/GetEnvById", method = RequestMethod.POST)
    public Object getEnvById(@RequestBody ConfigEntity  configEntity){
        Object result = configService.getEnvConfigById(configEntity.getEnv_id());

        return result;
    }
    /**
     * 请求头配置*/
    @RequestMapping(value= "/AddHeader", method = RequestMethod.POST)
    public Object AddHeader(@RequestBody ConfigEntity configEntity){
        Object result = configService.insertHerderConfig(configEntity);
        return result;
    }
    @RequestMapping(value= "/UpdateHeader", method = RequestMethod.POST)
    public Object UpdateHeader(@RequestBody ConfigEntity configEntity){
        Object result = configService.updateHerderConfig(configEntity);
        return result;
    }
    @RequestMapping(value= "/HeaderList", method = RequestMethod.POST)
    public Object HeaderList(){
        Object result = configService.getHerderConfig();
        return result;
    }

    @RequestMapping(value= "/GetDict", method = RequestMethod.POST)
    public Object getDict(@RequestParam String key){
        Object result = configService.getDict(key);
        return result;
    }
    /***
     * 测试计划配置
     * */
    @RequestMapping(value= "/projectList", method = RequestMethod.POST)
    public Object projectList(){
        Object result = configService.getProject();
        return result;
    }
    @RequestMapping(value= "/PlanList", method = RequestMethod.POST)
    public Object PlanList(){
        Object result = configService.getTestPlan();
        return result;
    }
    @RequestMapping(value= "/GetPlanById", method = RequestMethod.POST)
    public Object GetPlanById(@RequestBody CaseRuningEntity caseRuningEntity){
        Object result = configService.getTestPlanById(caseRuningEntity.getPlan_id());
        return result;
    }
    @RequestMapping(value= "/UpdatePlan", method = RequestMethod.POST)
    public Object UpdatePlan(@RequestBody CaseRuningEntity caseRuningEntity){
        Object result = configService.updateTestPlan(caseRuningEntity);
        return result;
    }
    @RequestMapping(value= "/DelPlan", method = RequestMethod.POST)
    public Object DelPlan(@RequestBody CaseRuningEntity caseRuningEntity){
        Object result = configService.DelTestPlan(caseRuningEntity);
        return result;
    }
    @RequestMapping(value= "/InsertPlan", method = RequestMethod.POST)
    public Object InsertPlan(@RequestBody CaseRuningEntity caseRuningEntity){
        Object result = configService.inserTestPlan(caseRuningEntity);
        return result;
    }
}
